//
//  Logins.m
//  Login
//
//  Created by Sean on 3/23/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "Logins.h"


@implementation Logins
@synthesize allLogins;


-(id) init
{
	if(self = [super init])
	{
		allLogins = [NSMutableDictionary new];
		for(int i=0; i < 26; i++)
		{
			char alphabetchar[2];
			alphabetchar[0] = ((char) (65 + i));
			alphabetchar[1] = '\0';
			NSMutableArray* alphaList = [[NSMutableArray alloc] init];
			[allLogins setObject:alphaList forKey:[NSString stringWithCString:alphabetchar encoding: NSASCIIStringEncoding]];
			[alphaList release];
		}
		
		//add numbers
		NSMutableArray* alphaList = [[NSMutableArray alloc] init];
		[allLogins setObject:alphaList forKey:@"#"];
		[alphaList release];
		
		
	}
	
	return self;
	
}

-(void) addLogin:(NSString*)alpha:(NSString*)loginName: (NSString*) key: (NSString*)value
{
	Login* l = [[Login alloc] init:alpha:loginName:key:value];
	
	NSMutableArray* alphaList =[self getAllValuesForAlpha:alpha];
	[alphaList addObject:l];
	
	//[l release];
}

-(NSMutableArray*) getAllValuesForAlpha:(NSString*)alpha
{
	return [allLogins objectForKey:alpha];	
}
	

-(NSMutableArray*) getAllValuesForAlphaIndex:(NSInteger)index
{
	if(index < 26){
	char alphabetchar[2];
	alphabetchar[0] = ((char) (65 + index));
	alphabetchar[1] = '\0';
	
	return [allLogins objectForKey:[NSString stringWithCString:alphabetchar encoding: NSASCIIStringEncoding]];	
	}
	else
		return [allLogins objectForKey:@"#"];	
}

-(void) dealloc
{
	[allLogins release];
	[super dealloc];	
}

@end
